const Postings = require('../model/Postings.js');
var multer = require('multer');
var storage = multer.diskStorage({
	destination: '../datas/imgs',
	filename: function(req, res, callback){
		var name = new Date().getDay();
		var random = Math.random();
		callback(null, name + random + ".png")
	}
})
var uploads = multer({storage});
module.exports = {
	addPosting: function(req, res){
		Postings.addPosting(req.body, (err, data)=>{
			if(!err){
				res.send('succeed');
			}
		});
	},
	getAllPostings: function(req, res){
		Postings.getAllPostings((err, data)=>{
			if(!err){
				res.send(data);
			}
		});
	}
}